3.2 \(\int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx\)

Optimal. Leaf size=24 \[ \frac{1}{3} a \sin ^3(x)+\frac{1}{3} b \cos ^3(x)-b \cos (x) \]

[Out]

-(b*Cos[x]) + (b*Cos[x]^3)/3 + (a*Sin[x]^3)/3

________________________________________________________________________________________

Rubi [A]  time = 0.041309, antiderivative size = 24, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 4, integrand size = 14, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.286, Rules used = {3089, 2564, 30, 2633} \[ \frac{1}{3} a \sin ^3(x)+\frac{1}{3} b \cos ^3(x)-b \cos (x) \]

Antiderivative was successfully verified.

[In]

Int[Sin[x]^2*(a*Cos[x] + b*Sin[x]),x]

[Out]

-(b*Cos[x]) + (b*Cos[x]^3)/3 + (a*Sin[x]^3)/3

Rule 3089

Int[sin[(c_.) + (d_.)*(x_)]^(m_.)*(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(n_.), x_Sym
bol] :> Int[ExpandTrig[sin[c + d*x]^m*(a*cos[c + d*x] + b*sin[c + d*x])^n, x], x] /; FreeQ[{a, b, c, d}, x] &&
 IntegerQ[m] && IGtQ[n, 0]

Rule 2564

Int[cos[(e_.) + (f_.)*(x_)]^(n_.)*((a_.)*sin[(e_.) + (f_.)*(x_)])^(m_.), x_Symbol] :> Dist[1/(a*f), Subst[Int[
x^m*(1 - x^2/a^2)^((n - 1)/2), x], x, a*Sin[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n - 1)/2] &&
 !(IntegerQ[(m - 1)/2] && LtQ[0, m, n])

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 2633

Int[sin[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> -Dist[d^(-1), Subst[Int[Expand[(1 - x^2)^((n - 1)/2), x], x], x
, Cos[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[(n - 1)/2, 0]

Rubi steps

\begin{align*} \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx &=\int \left (a \cos (x) \sin ^2(x)+b \sin ^3(x)\right ) \, dx\\ &=a \int \cos (x) \sin ^2(x) \, dx+b \int \sin ^3(x) \, dx\\ &=a \operatorname{Subst}\left (\int x^2 \, dx,x,\sin (x)\right )-b \operatorname{Subst}\left (\int \left (1-x^2\right ) \, dx,x,\cos (x)\right )\\ &=-b \cos (x)+\frac{1}{3} b \cos ^3(x)+\frac{1}{3} a \sin ^3(x)\\ \end{align*}

Mathematica [A]  time = 0.0038364, size = 26, normalized size = 1.08 \[ \frac{1}{3} a \sin ^3(x)-\frac{3}{4} b \cos (x)+\frac{1}{12} b \cos (3 x) \]

Antiderivative was successfully verified.

[In]

Integrate[Sin[x]^2*(a*Cos[x] + b*Sin[x]),x]

[Out]

(-3*b*Cos[x])/4 + (b*Cos[3*x])/12 + (a*Sin[x]^3)/3

________________________________________________________________________________________

Maple [A]  time = 0.021, size = 20, normalized size = 0.8 \begin{align*} -{\frac{b \left ( 2+ \left ( \sin \left ( x \right ) \right ) ^{2} \right ) \cos \left ( x \right ) }{3}}+{\frac{a \left ( \sin \left ( x \right ) \right ) ^{3}}{3}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(x)^2*(a*cos(x)+b*sin(x)),x)

[Out]

-1/3*b*(2+sin(x)^2)*cos(x)+1/3*a*sin(x)^3

________________________________________________________________________________________

Maxima [A]  time = 1.12823, size = 27, normalized size = 1.12 \begin{align*} \frac{1}{3} \, a \sin \left (x\right )^{3} + \frac{1}{3} \,{\left (\cos \left (x\right )^{3} - 3 \, \cos \left (x\right )\right )} b \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="maxima")

[Out]

1/3*a*sin(x)^3 + 1/3*(cos(x)^3 - 3*cos(x))*b

________________________________________________________________________________________

Fricas [A]  time = 0.483446, size = 77, normalized size = 3.21 \begin{align*} \frac{1}{3} \, b \cos \left (x\right )^{3} - b \cos \left (x\right ) - \frac{1}{3} \,{\left (a \cos \left (x\right )^{2} - a\right )} \sin \left (x\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="fricas")

[Out]

1/3*b*cos(x)^3 - b*cos(x) - 1/3*(a*cos(x)^2 - a)*sin(x)

________________________________________________________________________________________

Sympy [A]  time = 0.35743, size = 27, normalized size = 1.12 \begin{align*} \frac{a \sin ^{3}{\left (x \right )}}{3} - b \sin ^{2}{\left (x \right )} \cos{\left (x \right )} - \frac{2 b \cos ^{3}{\left (x \right )}}{3} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)**2*(a*cos(x)+b*sin(x)),x)

[Out]

a*sin(x)**3/3 - b*sin(x)**2*cos(x) - 2*b*cos(x)**3/3

________________________________________________________________________________________

Giac [A]  time = 1.10847, size = 34, normalized size = 1.42 \begin{align*} \frac{1}{12} \, b \cos \left (3 \, x\right ) - \frac{3}{4} \, b \cos \left (x\right ) - \frac{1}{12} \, a \sin \left (3 \, x\right ) + \frac{1}{4} \, a \sin \left (x\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="giac")

[Out]

1/12*b*cos(3*x) - 3/4*b*cos(x) - 1/12*a*sin(3*x) + 1/4*a*sin(x)